import React from "react";
import HeaderCss from "./header.scss";
import cookie from 'react-cookies'
import { withRouter } from 'react-router-dom';
import urlConfig from '../../utils/urlConfig'

export class Header extends React.Component{
    state = {
        visible:false,
        chkTrialInfo: false,
        is_trial:'',
        token:'',
        username:''
    }
    componentDidMount() {
        this.setUrlConfig();//设置url配置信息
        let username = ''
        this.setState({ username })
    }
    setUrlConfig = () => {
        urlConfig.data(res => {
            console.log(res, '地址信息11111111111111')
        })
    }
    toUp = () => {
        this.setState({
            visible: true
        })
    }
    handleCancel = e => {
        console.log(e);
        this.setState({
            visible: false
        })
    }
    loginOut = () => {
        cookie.remove('station_console_setting_web_login');
        sessionStorage.removeItem('urlConfig');
        this.props.history.push({ pathname: `/login` })
    }
    toHome = () => {
        this.props.history.push({ pathname: '/' })
    }
    render(){
        return (
            <div className={HeaderCss.header}>
                <div className={HeaderCss.logoImg}>
                    <img alt="" src={require("../../assets/img/log.png")} onClick={this.toHome}></img>
                    <span className={HeaderCss.version}>v1.6</span>
                </div>
                <div className={HeaderCss.loginSuccess}>
                    <div className={HeaderCss.loginOut}>
                        <span onClick={this.loginOut}>系统登出</span>
                        <img alt="" src={require("../../assets/img/loginOut.png")}></img>
                    </div>
                </div>
            </div>
        )
    };
};

export default withRouter(Header);